import QtQuick 2.0


Item {
    id: newsSelector
    anchors.top: content.top
    anchors.topMargin: 5
    anchors.left: content.left
    anchors.leftMargin: 5
    width: content.width - 10
    height: content.height - 10

    property string selected : "#FF274E13"
    property string unselected :  "#FF38761D"

    function startUp(){
        newsColumn.visible = true;
        newsWebView.visible = false;
        newsWebView.url = "";
        backButton.visible = false;
        forwardButton.visible = false;
    }

    Column{
        id:newsColumn
        anchors.top: parent.top
        anchors.topMargin: 10
        width: parent.width
        spacing: 20
        Grid {
            anchors.left: parent.left
            anchors.leftMargin: 38
            anchors.top: parent.top
            anchors.topMargin: 60
            width: parent.width - 76
            height: parent.height - 120
            columns: 8
            rows: 3
            spacing: 145
            Button {
                img: "images/cnn.png"
                text: "CNN"
                onClicked: {
                    newsWebView.url = "http://www.cnn.com/";
                    newsWebView.visible = true;
                    newsColumn.visible = false;
                    backButton.visible = true;
                    forwardButton.visible = true;
                }
            }
            Button {
                img: "images/cnbc.png"
                text: "CNBC"
                onClicked: {
                    newsWebView.url = "http://www.cnbc.com/";
                    newsWebView.visible = true;
                    newsColumn.visible = false;
                    backButton.visible = true;
                    forwardButton.visible = true;
                }
            }
            Button {
                img: "images/newYork.png"
                text: "New York"
                text2: "Times"
                onClicked: {
                    newsWebView.url = "http://www.nytimes.com/";
                    newsWebView.visible = true;
                    newsColumn.visible = false;
                    backButton.visible = true;
                    forwardButton.visible = true;
                }
            }
            Button {
                img: "images/npr.png"
                text: "National"
                text2: "Public Radio"
                onClicked: {
                    newsWebView.url = "http://www.npr.org/";
                    newsWebView.visible = true;
                    newsColumn.visible = false;
                    backButton.visible = true;
                    forwardButton.visible = true;
                }
            }

    }
    }

        AppButton {
            id: backButton
            text : "back"
            selected: newsSelector.selected
            unselected: newsSelector.unselected
            anchors.top:  parent.top
            anchors.topMargin: 10
            anchors.right: parent.right
            anchors.rightMargin: 150
            visible: true
            onClicked: {
                newsWebView.dynamicWebView.goBack();
            }
        }

        AppButton {
            id: forwardButton
            text : "forward"
            selected: newsSelector.selected
            unselected: newsSelector.unselected
            anchors.top:  parent.top
            anchors.topMargin: 10
            anchors.right: parent.right
            anchors.rightMargin: 30
            visible: true
            onClicked: {
                newsWebView.dynamicWebView.goForward();
            }
        }


        CustomWebView{
            id : newsWebView
            url : ""
            width: parent.width
            anchors.top: parent.top
            anchors.topMargin: 70
            height : 725
            visible : false
        }




}


